<template>
  <el-container class="home_container">
    <!-- 头部区域 -->
    <el-header>
      <div>
        <img class="head_png" src="../assets/head.png" alt="">
        <span>惊蛰的当铺</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏 -->
      <!-- 隐藏侧边栏按钮 -->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <!-- 侧边栏菜单区域 -->
        <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        background-color="#FA5858"
        text-color="#fff"
        active-text-color="#ffd04b"
        :unique-opend="true"
        :collapse="isCollapse"
        :collapse-transition="false"
        :router="true">
          <!-- 商品部分 -->
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-shopping-cart-1"></i>
              <span>商品列表</span>
            </template>
            <el-menu-item index="dailyNecessarites">日用品</el-menu-item>
              <el-menu-item index="places">场地</el-menu-item>
          </el-submenu>
          <!-- 购物车部分 -->
          <el-menu-item index="shopCart">
            <i class="el-icon-s-order"></i>
            <span slot="title">我的购物车</span>
          </el-menu-item>
          <!-- 我的订单信息部分 -->
          <el-submenu index="2.5">
            <template slot="title">
              <i class="el-icon-document"></i>
              <span>我的订单信息</span>
            </template>
          
            <el-menu-item index="userOrders">我申请的订单</el-menu-item>
            <el-menu-item index="userOrdersToMe">我收到的订单</el-menu-item>

            
          </el-submenu>
          <!-- 我的个人信息部分 -->
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-document"></i>
              <span>我的个人信息</span>
            </template>
            <el-menu-item index="userInformation">我的基本信息</el-menu-item>
            <el-menu-item index="userUpdate">修改我的信息</el-menu-item>
            <el-menu-item index="userRecharge">账户充值</el-menu-item>
          </el-submenu>
          <!-- 提交出租物部分 -->
          <el-menu-item index="release">
            <i class="el-icon-upload2"></i>
            <span slot="title">我要发布</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 右侧内容区域 -->
      <el-main>
        <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      //左侧菜单栏数据
      // 是否折叠
      isCollapse: false
    }
  },
  methods: {
    logout() {
    window.sessionStorage.clear()
    this.$router.push('/login')
    },
    //隐藏侧边栏函数
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style lang="less" scoped>
.home_container {
  height: 100%;
}

.el-header {
  background-color: #F5A9A9;// #373D41;
  display: flex;
  // 左右对齐
  justify-content: space-between;
  padding-left: 0;
  // 使按钮居中
  align-items: center;
  object-fit: cover;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 25px;
    }
  }
}

.head_png {
  height: 100%;
  width: 200px;
}

.el-aside {
  background-color: #F6CECE;//#333744;
}

.el-main {
  background-color:#f0dada;
}

.toggle-button {
  background-color: #F6CECE;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>